/**
 * @author lteng
 * @time 2022-06-18 19:05:52 
 */
 
package liteng.study.cn.stuscore.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import liteng.study.cn.stuscore.service.ScoreService;
import liteng.study.cn.stuscore.service.impl.ScoreServiceImpl;

/**
 * 学生成绩请求控制器
 */
@WebServlet("/score")
public class ScoreServlet extends HttpServlet {
	ScoreService scoreService = new ScoreServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("score-get启动");
		request.setCharacterEncoding("UTF-8");
		String action = request.getParameter("action");
		if (action.equals("edit")) {
			editScore(request,response);
		}
		
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}
	
	/**
	 * 
	 * @param request
	 * @param response
	 */
	private void editScore(HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
//		System.out.println("编辑！！");
		String [] sIds = request.getParameterValues("sIds[]");
		String[] scores = request.getParameterValues("scores[]");
		int eId = Integer.valueOf(request.getParameter("eId"));
		System.out.println("编辑！！"+sIds);
		scoreService.editScore(sIds, scores, eId);
		
	}

	
}
